package swordoffer.offer06;

import java.util.ArrayList;
import java.util.List;

public class Recur {
    public ArrayList<Integer> printListFromTailToHead(ListNode listNode) {
        ArrayList<Integer> res = new ArrayList<>();
        if(listNode == null){
            return res;
        }
        recur(listNode, res);
        return res;
    }
    public void recur(ListNode head, ArrayList<Integer> res){
        if(head == null){
            return;
        }
        recur(head.next,res);
        res.add(head.val);
    }
}
